package apis.amapv2.com.io;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import java.util.ArrayList;
import java.util.List;

import apis.amapv2.com.io.activity.BaseQuestionActivity;
import apis.amapv2.com.io.addpter.ItemAdapter;
import apis.amapv2.com.io.assets.AssetsMainActivity;
import apis.amapv2.com.io.bean.ItemObject;
import apis.amapv2.com.io.inoutstream.InOutStremActivity;

public class MainActivity extends AppCompatActivity {

    private Context mContext;
    private ListView mLv;
    private List<ItemObject> mData = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        intParamsAndValus();

        initView();

        initData();
    }

    private void intParamsAndValus() {
        mContext = this;

        mData.add(new ItemObject("流的概念",BaseQuestionActivity.class));
        mData.add(new ItemObject("FileInputStream_^-^_FileOutPutStream",InOutStremActivity.class));
        mData.add(new ItemObject("assets相关",AssetsMainActivity.class));
    }

    private void initView() {
        mLv = findViewById(R.id.lv);
        mLv.setAdapter(new ItemAdapter(mContext,mData));
        mLv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                startActivity(new Intent(mContext,mData.get(position).getClazz()));
            }
        });
    }

    private void initData() {

    }
}
